package com.xiaoshuidi.cloud.module.rooms.controller.app.reserve;

import com.xiaoshuidi.cloud.framework.common.pojo.CommonResult;
import com.xiaoshuidi.cloud.framework.common.pojo.PageResult;
import com.xiaoshuidi.cloud.module.rooms.controller.admin.reservation.vo.RoomReceiptRespVO;
import com.xiaoshuidi.cloud.module.rooms.controller.app.reserve.vo.MyReservePageRespVO;
import com.xiaoshuidi.cloud.module.rooms.controller.app.reserve.vo.ReceiptPageRespVO;
import com.xiaoshuidi.cloud.module.rooms.enums.ApiConstants;
import com.xiaoshuidi.cloud.module.rooms.service.IRoomHouseReserveService;
import com.xiaoshuidi.cloud.module.rooms.service.RoomReceiptService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

import static com.xiaoshuidi.cloud.framework.common.pojo.CommonResult.success;

@Tag(name = "租客端 - 预定账单收据")
@RestController
@RequiredArgsConstructor
@RequestMapping(ApiConstants.NAME + "/receipt")
public class ReceiptController {

    private final RoomReceiptService roomReceiptService;

    @Operation(summary = "查询预定账单收据")
    @GetMapping("/get")
    public CommonResult<RoomReceiptRespVO> getReceiptById(@RequestParam("id") Long id){
        return success(roomReceiptService.get(id));
    }

    @Operation(summary = "查询预定账单收据列表")
    @GetMapping("/page")
    @Parameters({
            @Parameter(name = "pageNum", description = "页码"),
            @Parameter(name = "pageSize", description = "页大小")
    })
    public CommonResult<PageResult<ReceiptPageRespVO>> getReceiptPage(Integer pageNum, Integer pageSize){
        return success(roomReceiptService.page(pageNum,pageSize));
    }

    @Operation(summary = "下载预定账单收据")
    @GetMapping("/down")
    public CommonResult<String> downReceiptById(@RequestParam("id") Long id){
        return success(roomReceiptService.downPdf(id));
    }
}
